home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / HyperCard Related / XCMDs & XFCNs / ProgressWindoid / ProgressWindoid.p < prev    next >
Encoding:
Text File  |  1991-03-29  |  18.2 KB  |  624 lines  |  [TEXT/MPS ]

  1. {
  2.     Written by Chris Thorman.  Based on an example by Jay Hodgdon.
  3.     Copyright 1990 Apple Computer, Inc.
  4.     
  5.     Permission granted for any kind of use as long as this notice is retained.
  6.     
  7.     Apple makes no claims as to the correctness or value of this software for
  8.     any purpose.  In fact, this software may well have bugs which will crash
  9.     your machine at crucial moments.
  10. }
  11.  
  12. {$R-}
  13. {$S ProgressWindoid  }
  14.  
  15.     ProgressWindoid (WindowName, Loc, [Width, Text, Fraction, TextFont, TextSize])
  16.         
  17.     This HyperCard external window command creates a windoid that can be used
  18.     to show progress of a lengthy operation.
  19.     
  20.     The XFCN is called once and if successful, leaves an XWindoid which 
  21.     HyperCard will subsequently manage.  A successful call is indicated
  22.     by an empty return value from the XFCN.  If the return value is not
  23.     empty, then it should be interpreted as an error message.
  24.     
  25.     All interaction with the window takes place by getting and setting
  26.     its properties (see below), and through HyperCard’s open, close, show,
  27.     and hide commands.
  28.     
  29.     The WindowName argument is the name that the window will be given.  It
  30.     is required.  After creating the window, this name will be used from
  31.     HyperTalk to refer to it.
  32.  
  33.     The Loc argument is the point that will become the upper-left corner
  34.     of the windoid.  It is a two-item string in the form “20,50”.  It is 
  35.     a card-relative number, not screen relative.  It is required.
  36.     
  37.     The optional Width argument is total width of the windoid in pixels.  The 
  38.     minimum width is 140 pixels.  The maximum is 1200 pixels.  The default
  39.     is 250 pixels.
  40.     
  41.     The optional Text argument is the text that appears above the
  42.     progress bar in the windoid.  It may be empty.  It defaults to “Progress:”.
  43.     
  44.     The optional Fraction argument is the Fraction that the XWindoid
  45.     starts with when it is created.  It is a floating point number between
  46.     0.0 and 1.0.  It defaults to 0.0.
  47.     
  48.     The optional TextFont argument is the font that will be used for the text
  49.     in the windoid.  The name of the font (e.g. “Helvetica”) is used to specify
  50.     the font.  The default font is whatever font corresponds to 0 on the current
  51.     system (usually Geneva).
  52.     
  53.     The optional TextSize argument is the size of the text in the window.  It
  54.     is 12 by default.  The minimum size is 1 point and the maximum size is 127
  55.     points.
  56.     
  57.     All of the optional arguments correspond to HyperCard properties of the
  58.     windoid.  These are: the width, the text, the fraction, the textFont, and
  59.     the textSize.
  60.     
  61.     In addition to these special properties, the windoid also supports 
  62.     HyperCard’s standard window properties: the loc, the visible, and the
  63.     properties (which returns a list of the special properties of the windoid).
  64.     
  65.  }
  66.  
  67. UNIT DummyUnit;
  68.  
  69. INTERFACE
  70.  
  71.     USES
  72.     {    Traps, Desk, OSUtils, }
  73.         Files, ToolUtils, Memory, Windows, SANE, Fonts,
  74.         Types, Events, TextEdit, Menus, HyperXCmd;
  75.  
  76.     PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  77.  
  78. IMPLEMENTATION
  79.         
  80.     PROCEDURE ProgressWindoid (paramPtr: XCmdPtr);
  81.     FORWARD;
  82.  
  83.     PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  84.     BEGIN
  85.         ProgressWindoid (paramPtr)
  86.     END { entrypoint } ;
  87.  
  88.         
  89.     PROCEDURE ProgressWindoid (paramPtr: XCmdPtr);
  90.     
  91.     CONST
  92.     
  93.     MinParams =        2;
  94.     MaxParams =        7;
  95.     
  96.     TextTopSpace = 5;
  97.     TextBottomSpace = 5;
  98.  
  99.     TextLeftSideSpace = 20;
  100.     
  101.  
  102. {    ProgBarTop        }    { = TextTopSpace + TextSize + TextBottomSpace} 
  103.     ProgBarSideSpace = 20;
  104.  
  105. {    ProgBarWidth      } { = WindowWidth - (2 * ProgBarSideSpace) }
  106.     ProgBarHeight = 20;
  107.     ProgBarBottomSpace = 10;
  108.     
  109.  
  110. {    WindowWidth       } { Determined by user }
  111. {    WindowHeight      } { = ProgBarTop +  ProgBarHeight + ProgBarBottomSpace } 
  112.  
  113.     
  114.     TYPE
  115.     
  116.     ParamArray =        PACKED ARRAY [1..MaxParams] OF Str255;
  117.     
  118.     ProgressWindoidInfoRecord = RECORD
  119.         WindowText:            Str255;
  120.         WindowFraction:        Extended;
  121.         ProgBarTop:            Integer; { Cached here, but could be determined from txSize }
  122.         ProgBarWidth:        Integer; { Cached here, but could be determined from portRect }
  123.         END;
  124.         
  125.     ProgressWindoidInfoPtr = ^ProgressWindoidInfoRecord;
  126.     ProgressWindoidInfoHandle = ^ProgressWindoidInfoPtr;
  127.     
  128.     VAR
  129.     TheResult:                    Handle;
  130.     
  131.     ParamStrings:                ParamArray;
  132.  
  133.     WindowNameParam:            Str255;
  134.     LocParam:                    Point;
  135.     WidthParam:                    Integer;
  136.     TextParam:                    Str255;
  137.     FractionParam:                Extended;
  138.     TextFontParam:                Integer;
  139.     TextSizeParam:                Integer;
  140.     
  141.     WindowBounds:                Rect;
  142.     MyWindowPtr:                WindowPtr;
  143.  
  144.     ProgWindInfo:                ProgressWindoidInfoHandle;
  145.     
  146.         PROCEDURE ExitWithHandle(aHandle: Handle);
  147.         BEGIN
  148.             ZeroTermHandle(paramPtr, aHandle);
  149.             WITH paramPtr^ DO BEGIN
  150.                 returnValue := aHandle;
  151.                 EXIT(ProgressWindoid);
  152.             END;
  153.         END;
  154.             
  155.         PROCEDURE ExitWithMessage(aString: Str255);
  156.         BEGIN
  157.             WITH paramPtr^ DO BEGIN
  158.                 returnValue := PasToZero(paramPtr, aString);
  159.                 EXIT(ProgressWindoid);
  160.             END;
  161.         END;
  162.             
  163.         PROCEDURE ExitWithError(aString: Str255);
  164.         BEGIN
  165.             ExitWithMessage(concat('•••••••• Error: ', aString, '.'));
  166.         END;
  167.                         
  168.         PROCEDURE LimitFractionValue(VAR Fraction: Extended);
  169.         BEGIN
  170.             IF (ClassExtended(Fraction) <> NormalNum) THEN Fraction := 0.0;
  171.             IF (Fraction < 0.0) THEN Fraction := 0.0;
  172.             IF (Fraction > 1.0) THEN Fraction := 1.0;
  173.         END;
  174.  
  175.         PROCEDURE LimitWidthValue(VAR WindWidth: Integer);
  176.         BEGIN
  177.             IF (WindWidth < 140) THEN WindWidth := 140;
  178.             IF (WindWidth > 1200) THEN WindWidth := 1200;
  179.         END;
  180.  
  181.         PROCEDURE LimitTextSizeValue(VAR TextSize: Integer);
  182.         BEGIN
  183.             IF (TextSize < 1) THEN TextSize := 12;
  184.             IF (TextSize > 127) THEN TextSize := 12;
  185.         END;
  186.  
  187.         PROCEDURE ParseParams;
  188.         VAR
  189.             ParamNum:            integer;
  190.         BEGIN
  191.             WITH paramPtr^ DO BEGIN
  192.                 IF (paramCount < MinParams) THEN ExitWithError('Too few parameters');
  193.                 IF (paramCount > MaxParams) THEN ExitWithError('Too many parameters');
  194.                 
  195.                 ParamNum := 1; {* Required *}
  196.                 
  197.                 ZeroToPas(paramPtr, params[ParamNum]^, ParamStrings[ParamNum]);  
  198.                 WindowNameParam := ParamStrings[ParamNum];
  199.                 IF (WindowNameParam = '') THEN ExitWithError('Empty window name was given');
  200.             
  201.                 ParamNum := 2; {* Required *}
  202.                 
  203.                 ZeroToPas(paramPtr, params[ParamNum]^, ParamStrings[ParamNum]);  
  204.                 StrToPoint(paramPtr, ParamStrings[ParamNum], LocParam);
  205.                 
  206.                 { LocParam is passed in as card-relative, but we will need absolute
  207.                   coordinates. }
  208.                 { As it happens, LocalToGlobal accomplishes this, but the more correct
  209.                   way would probably be to use EvalExpr(paramPtr, 'the loc of card window')
  210.                   and add that loc to the loc that was passed in. }
  211.                   
  212.                  LocalToGlobal(LocParam);
  213.                 
  214.                 ParamNum := 3; {* Optional *}
  215.                 
  216.                 IF (paramCount >= ParamNum) THEN
  217.                     BEGIN
  218.                         ZeroToPas(paramPtr, params[ParamNum]^, ParamStrings[ParamNum]);  
  219.                         WidthParam := StrToNum(paramPtr, ParamStrings[ParamNum]);
  220.                         LimitWidthValue(WidthParam);
  221.                     END
  222.                 ELSE
  223.                     BEGIN
  224.                         WidthParam := 250;
  225.                     END;    
  226.                 
  227.                 ParamNum := 4; {* Optional *}
  228.                 
  229.                 IF (paramCount >= ParamNum) THEN
  230.                     BEGIN
  231.                         ZeroToPas(paramPtr, params[ParamNum]^, ParamStrings[ParamNum]);  
  232.                         TextParam := ParamStrings[ParamNum];
  233.                     END
  234.                 ELSE
  235.                     BEGIN
  236.                         TextParam := 'Progress:';
  237.                     END;    
  238.                 
  239.                 ParamNum := 5; {* Optional *}
  240.                 
  241.                 IF (paramCount >= ParamNum) THEN
  242.                     BEGIN
  243.                         ZeroToPas(paramPtr, params[ParamNum]^, ParamStrings[ParamNum]);  
  244.                         IF (ParamStrings[ParamNum] = '') THEN FractionParam := 0.0
  245.                         ELSE FractionParam := StrToExt(paramPtr, ParamStrings[ParamNum]);
  246.                         LimitFractionValue(FractionParam);
  247.                     END
  248.                 ELSE
  249.                     BEGIN
  250.                         FractionParam := 0.0;
  251.                     END;    
  252.                 
  253.                 ParamNum := 6; {* Optional *}
  254.                 
  255.                 IF (paramCount >= ParamNum) THEN
  256.                     BEGIN
  257.                         ZeroToPas(paramPtr, params[ParamNum]^, ParamStrings[ParamNum]);  
  258.                         GetFNum(ParamStrings[ParamNum], TextFontParam);
  259.                     END
  260.                 ELSE
  261.                     BEGIN
  262.                         TextFontParam := 0;
  263.                     END;    
  264.                 
  265.                 ParamNum := 7; {* Optional *}
  266.                 
  267.                 IF (paramCount >= ParamNum) THEN
  268.                     BEGIN
  269.                         ZeroToPas(paramPtr, params[ParamNum]^, ParamStrings[ParamNum]);  
  270.                         TextSizeParam := StrToNum(paramPtr, ParamStrings[ParamNum]);
  271.                         LimitTextSizeValue(TextSizeParam);
  272.                     END
  273.                 ELSE
  274.                     BEGIN
  275.                         TextSizeParam := 12;
  276.                     END;    
  277.                 
  278.             END;
  279.             
  280.         END;        { ParseParams }
  281.             
  282.         PROCEDURE DoSetup;
  283.         VAR
  284.             ProgBarTop:            Integer;
  285.             ProgBarWidth:        Integer;
  286.             WindowHeight:        Integer;
  287.         BEGIN
  288.             { Put values into the parameter variables or fail trying. }
  289.             ParseParams;    
  290.             
  291.             ProgBarTop := TextTopSpace + TextSizeParam + TextBottomSpace;
  292.             ProgBarWidth := WidthParam - (2 * ProgBarSideSpace);
  293.  
  294.             WindowHeight := ProgBarTop +  ProgBarHeight + ProgBarBottomSpace;
  295.             
  296.             WindowBounds.Left :=     LocParam.h;
  297.             WindowBounds.Top :=     LocParam.v;
  298.             WindowBounds.Right :=     LocParam.h + WidthParam;
  299.             WindowBounds.Bottom :=     LocParam.v + WindowHeight;
  300.  
  301.             ProgWindInfo := ProgressWindoidInfoHandle(NewHandle(Sizeof(ProgressWindoidInfoRecord)));
  302.             IF (ProgWindInfo = NIL) THEN ExitWithError('Couldn’t allocate storage for window variables');
  303.             
  304.             MyWindowPtr := NewXWindow(paramPtr, WindowBounds, WindowNameParam, FALSE, 
  305.                                 palNoGrowProc, FALSE, TRUE);
  306.                                 
  307.             IF (MyWindowPtr = NIL) THEN 
  308.                 BEGIN
  309.                     DisposHandle(Handle(ProgWindInfo));
  310.                     ExitWithError('Couldn’t create XWindow');
  311.                 END;
  312.                 
  313.             MyWindowPtr^.txFont := TextFontParam;
  314.             MyWindowPtr^.txSize := TextSizeParam;
  315.             
  316.             { All of the XWindow’s variables must be stored in a handle to a
  317.               record (of type ProgressWindoidInfoRecord whose fields are declared at the top) and then
  318.               this handle is stored in the WRefCon of the window once it is created.
  319.               This way they can be accessed again when the window receives messages.
  320.               The handle is destroyed when the window gets its goodbye kiss.
  321.             }
  322.               
  323.             ProgWindInfo^^.WindowText         := TextParam;
  324.             ProgWindInfo^^.WindowFraction     := FractionParam;
  325.             ProgWindInfo^^.ProgBarTop         := ProgBarTop;
  326.             ProgWindInfo^^.ProgBarWidth     := ProgBarWidth;
  327.             
  328.             SetWRefCon(MyWindowPtr, LONGINT(ProgWindInfo));
  329.  
  330.         END;
  331.  
  332.         PROCEDURE KillXWindow(ProgWindInfo: ProgressWindoidInfoHandle; theWindow: WindowPtr);
  333.         { dispose of the window's data structures }
  334.         BEGIN
  335.             
  336.             { None of the fields in the XWindowInfoRec need to be destroyed,
  337.                 just the handle itself. }
  338.             DisposHandle(Handle(ProgWindInfo));
  339.         END;
  340.     
  341.  
  342.         PROCEDURE DrawText(ProgWindInfo: ProgressWindoidInfoHandle; theWindow: WindowPtr);
  343.         VAR    
  344.             TextRect:        Rect;
  345.             FInfo:            FontInfo;
  346.             WindowWidth:    Integer;
  347.         BEGIN
  348.             GetFontInfo(FInfo);
  349.             
  350.             WindowWidth := TheWindow^.portRect.Right - TheWindow^.portRect.Left;
  351.             
  352.             SetRect(TextRect, TextLeftSideSpace, TextTopSpace, 
  353.                                 WindowWidth, TextTopSpace + FInfo.ascent + FInfo.descent);
  354.             EraseRect(TextRect);
  355.             
  356.             MoveTo(TextLeftSideSpace,TextTopSpace + FInfo.ascent);
  357.             DrawString(ProgWindInfo^^.WindowText);
  358.         END;
  359.         
  360.         PROCEDURE DrawProgBar(ProgWindInfo: ProgressWindoidInfoHandle; theWindow: WindowPtr);
  361.         VAR    
  362.             ProgressBar:        Rect;
  363.             CompletionBar:        Rect;
  364.             UnCompleteBar:        Rect;
  365.         BEGIN
  366.                 
  367.             SetRect(ProgressBar, ProgBarSideSpace, ProgWindInfo^^.ProgBarTop, 
  368.                                     ProgBarSideSpace + ProgWindInfo^^.ProgBarWidth, 
  369.                                     ProgWindInfo^^.ProgBarTop + ProgBarHeight);
  370.                                     
  371.             SetRect(CompletionBar, 
  372.                         ProgressBar.Left + 1, 
  373.                         ProgressBar.Top + 1, 
  374.                         ProgressBar.Left + 1 + Num2Integer((ProgWindInfo^^.ProgBarWidth - 1) * ProgWindInfo^^.WindowFraction), 
  375.                         ProgressBar.Bottom - 1);
  376.                                     
  377.             SetRect(UnCompleteBar, CompletionBar.Right, CompletionBar.Top, 
  378.                                     ProgBarSideSpace + ProgWindInfo^^.ProgBarWidth - 1, 
  379.                                     CompletionBar.Bottom);
  380.                                     
  381.             PaintRect(CompletionBar);
  382.             EraseRect(UncompleteBar);
  383.             FrameRect(ProgressBar);
  384.             
  385.         END;
  386.         
  387.         PROCEDURE DoUpdate(ProgWindInfo: ProgressWindoidInfoHandle; theWindow: WindowPtr);
  388.         VAR    
  389.             WindowRect:            Rect;
  390.         BEGIN
  391.             WindowRect := theWindow^.portRect;
  392.             
  393.             BeginUpdate(theWindow);
  394.             
  395.                 EraseRect(WindowRect);
  396.                 DrawText(ProgWindInfo, theWindow);
  397.                 DrawProgBar(ProgWindInfo, theWindow);
  398.                 
  399.             EndUpdate(theWindow);
  400.         END;
  401.         
  402.     
  403.         PROCEDURE DoMouseDown(ProgWindInfo: ProgressWindoidInfoHandle; theWindow: WindowPtr; theEvent: EventRecord);
  404.         BEGIN
  405.             CASE FindWindow(theEvent.where,theWindow) OF
  406.                 inGoAway:
  407.                     IF TrackGoAway(theWindow,theEvent.where) THEN
  408.                         CloseXWindow(paramPtr,theWindow);
  409.                         
  410.                 inDrag:            paramPtr^.passFlag:= TRUE;
  411.                 
  412.             {    inContent:    NOTHING }
  413.             
  414.             END; {case}
  415.         END;
  416.     
  417.         FUNCTION GetProperty(ProgWindInfo: ProgressWindoidInfoHandle; theWindow: WindowPtr; propName: StringPtr): Handle;
  418.         {The procedure causes the window to respond to a }
  419.         {get the myValue of window "TestWindow" }
  420.         VAR
  421.             TempString:        Str255;
  422.         BEGIN
  423.             IF StringEqual(paramPtr,propName^,'Properties') {List of all other properties}
  424.             THEN
  425.                 BEGIN
  426.                     GetProperty := PasToZero(paramPtr, 'Text,Fraction,Width,TextFont,TextSize');
  427.                     Exit(GetProperty);
  428.                 END;
  429.  
  430.             IF StringEqual(paramPtr,propName^,'Width')
  431.             THEN
  432.                 BEGIN
  433.                     NumToStr(paramPtr, TheWindow^.portRect.Right - TheWindow^.portRect.Left, TempString);
  434.                     GetProperty := PasToZero(paramPtr, TempString);
  435.                     Exit(GetProperty);
  436.                 END;
  437.  
  438.             IF StringEqual(paramPtr,propName^,'Text')
  439.             THEN
  440.                 BEGIN
  441.                     GetProperty := PasToZero(paramPtr, ProgWindInfo^^.WindowText);
  442.                     Exit(GetProperty);
  443.                 END;
  444.  
  445.             IF StringEqual(paramPtr,propName^,'Fraction') 
  446.             THEN
  447.                 BEGIN
  448.                     ExtToStr(paramPtr, ProgWindInfo^^.WindowFraction, TempString);
  449.                     GetProperty := PasToZero(paramPtr, TempString);
  450.                     Exit(GetProperty);
  451.                 END;
  452.  
  453.             IF StringEqual(paramPtr,propName^,'TextFont')
  454.             THEN
  455.                 BEGIN
  456.                     GetFontName(TheWindow^.txFont, TempString);
  457.                     GetProperty := PasToZero(paramPtr, TempString);
  458.                     Exit(GetProperty);
  459.                 END;
  460.  
  461.             IF StringEqual(paramPtr,propName^,'TextSize')
  462.             THEN
  463.                 BEGIN
  464.                     NumToStr(paramPtr, TheWindow^.txSize, TempString);
  465.                     GetProperty := PasToZero(paramPtr, TempString);
  466.                     Exit(GetProperty);
  467.                 END;
  468.  
  469.             { This handles the properties: loc, visible (HyperCard supplies them) }
  470.             GetProperty:= NIL;
  471.             paramPtr^.passFlag:= TRUE;
  472.         END;
  473.     
  474.         PROCEDURE SetProperty(ProgWindInfo: ProgressWindoidInfoHandle; theWindow: WindowPtr; propName: StringPtr; propVal: Handle);
  475.         {The procedure causes the window to respond to a }
  476.         {"set the yourValue of window "TestWindow" to something" }
  477.         VAR
  478.             TempString:            Str255;
  479.  
  480.             NewWidth:            Integer;
  481.             WindowHeight:        Integer;
  482.  
  483.             NewFontNumber:        Integer;
  484.  
  485.             NewSize:            Integer;
  486.             ProgBarTop:            Integer;
  487.             ProgBarWidth:        Integer;
  488.             NewHeight:            Integer;
  489.             WindowWidth:        Integer;
  490.         BEGIN
  491.             IF StringEqual(paramPtr,propName^,'Fraction') 
  492.             THEN
  493.                 BEGIN
  494.                     ZeroToPas(paramPtr, propVal^, TempString);
  495.                     ProgWindInfo^^.WindowFraction := StrToExt(paramPtr, TempString);
  496.                     LimitFractionValue(ProgWindInfo^^.WindowFraction);
  497.                     DrawProgBar(ProgWindInfo, theWindow);
  498.                 END
  499.                 
  500.             ELSE IF StringEqual(paramPtr,propName^,'Text')
  501.             THEN
  502.                 BEGIN
  503.                     ZeroToPas(paramPtr, propVal^, TempString);
  504.                     ProgWindInfo^^.WindowText := TempString;
  505.                     DrawText(ProgWindInfo, theWindow);
  506.                     { Sometimes the font misbehaves & draws in the progbar area }
  507.                     DrawProgBar(ProgWindInfo, theWindow);
  508.                 END
  509.                 
  510.             ELSE IF StringEqual(paramPtr,propName^,'Width')
  511.             THEN
  512.                 BEGIN
  513.                     ZeroToPas(paramPtr, propVal^, TempString);
  514.                     NewWidth := StrToNum(paramPtr, TempString);
  515.                     LimitWidthValue(NewWidth);
  516.                     ProgWindInfo^^.ProgBarWidth := NewWidth - (2 * ProgBarSideSpace);
  517.                     
  518.                     WindowHeight := theWindow^.portRect.Bottom - theWindow^.portRect.Top;
  519.                     SizeWindow(TheWindow, NewWidth, WindowHeight, TRUE); { forces an update event, maybe }
  520.                     InvalRect(theWindow^.portRect);
  521.                     
  522.                     DrawText(ProgWindInfo, theWindow);         { More or less text may fit now. }
  523.                     DrawProgBar(ProgWindInfo, theWindow);    { The progress bar will be longer or shorter now. }
  524.                 END
  525.                 
  526.             ELSE IF StringEqual(paramPtr,propName^,'TextFont')
  527.             THEN
  528.                 BEGIN
  529.                     ZeroToPas(paramPtr, propVal^, TempString);
  530.                     GetFNum(TempString, NewFontNumber); 
  531.                     TheWindow^.txFont := NewFontNumber; { Same as QuickDraw SetFont  }
  532.                                         
  533.                     DrawText(ProgWindInfo, theWindow);         { More or less text may fit now, but height is the same. }
  534.                     { Sometimes the font misbehaves & draws in the progbar area }
  535.                     DrawProgBar(ProgWindInfo, theWindow);
  536.                 END
  537.                 
  538.             ELSE IF StringEqual(paramPtr,propName^,'TextSize')
  539.             THEN
  540.                 BEGIN
  541.                     ZeroToPas(paramPtr, propVal^, TempString);
  542.                     NewSize := StrToNum(paramPtr, TempString);
  543.                     LimitTextSizeValue(NewSize);
  544.                     
  545.                     TheWindow^.txSize := NewSize;
  546.                     
  547.                     ProgBarTop := TextTopSpace + NewSize + TextBottomSpace;
  548.                     ProgWindInfo^^.ProgBarTop := ProgBarTop;
  549.                     
  550.                     NewHeight := ProgBarTop +  ProgBarHeight + ProgBarBottomSpace;
  551.                     WindowWidth := theWindow^.portRect.Right - theWindow^.portRect.Left;
  552.                     SizeWindow(TheWindow, WindowWidth, NewHeight, TRUE); { forces an update event, maybe }
  553.                     InvalRect(theWindow^.portRect);
  554.                     
  555.                     DrawText(ProgWindInfo, theWindow);         { More or less text may fit now. }
  556.                     DrawProgBar(ProgWindInfo, theWindow);    { The progress bar will be at a different height now. }
  557.                 END
  558.                 
  559.             ELSE 
  560.                 BEGIN { This handles the properties: loc, visible (HyperCard supplies them) }
  561.                     paramPtr^.passFlag:= TRUE;
  562.                 END;
  563.         END;
  564.  
  565.         PROCEDURE ProcessEvent(myXWEventInfoPtr: XWEventInfoPtr; myWindow: WindowPtr; myEvent: EventRecord);
  566.         VAR
  567.             ProgWindInfo:    ProgressWindoidInfoHandle;
  568.         BEGIN
  569.             ProgWindInfo := ProgressWindoidInfoHandle(GetWRefCon(myWindow));
  570.  
  571.             CASE myEvent.what OF
  572.                 mouseDown:                DoMouseDown(ProgWindInfo, myWindow, myEvent);
  573.                 updateEvt:                DoUpdate(ProgWindInfo, myWindow);
  574.                 app4Evt:                ShowHide(myWindow, ODD(myEvent.message));
  575.                 xCursorWithin:            paramPtr^.passFlag:= TRUE;
  576.                 
  577.                 xGetPropEvt: 
  578.                     myXWEventInfoPtr^.eventResult := 
  579.                         GetProperty(ProgWindInfo, myWindow,StringPtr(myXWEventInfoPtr^.eventParams[1]));
  580.                 xSetPropEvt:
  581.                     SetProperty(ProgWindInfo, myWindow,
  582.                                     StringPtr(myXWEventInfoPtr^.eventParams[1]),
  583.                                         Handle(myXWEventInfoPtr^.eventParams[2]));
  584.                 xCloseEvt:
  585.                     BEGIN
  586.                         KillXWindow(ProgWindInfo, myWindow);
  587.                         paramPtr^.passFlag:= TRUE;
  588.                     END;
  589.             END; {case}
  590.         END;
  591.  
  592.         PROCEDURE DoEvent;
  593.         VAR    
  594.             savePort:            GrafPtr;
  595.             myEvent:            EventRecord;
  596.             myWindow:            WindowPtr;
  597.             myXWEventInfoPtr:    XWEventInfoPtr;
  598.             
  599.         BEGIN
  600.             myXWEventInfoPtr := XWEventInfoPtr(paramPtr^.params[1]);
  601.             myWindow:= myXWEventInfoPtr^.eventWindow;
  602.             myEvent:= myXWEventInfoPtr^.event;
  603.  
  604.             GetPort(savePort);
  605.             SetPort(myWindow);
  606.             ProcessEvent(myXWEventInfoPtr, myWindow, myEvent);
  607.             SetPort(savePort);
  608.         END;
  609.  
  610.     BEGIN {ProgressWindoid }
  611.         WITH paramPtr^ DO
  612.         BEGIN
  613.             
  614.             IF (paramCount = -1) THEN DoEvent ELSE DoSetup;
  615.                         
  616.         END
  617.  
  618.     END { ProgressWindoid  } ;
  619.  
  620. END. { DummyUnit }
  621.  
  622.  
  623.